import { lazy } from "react";
import { useRoutes,Navigate } from "react-router-dom";

import {
    AppstoreOutlined,
} from '@ant-design/icons';

// import MyRouter1 from "./aa.js";

// 主界面
const MyLayout = lazy(()=>import('../components/MyLayout/MyLayout.jsx'))

// 资产
const ZC = lazy(()=>import('../components/zichan/ZC.jsx'));
const LY = lazy(()=>import('../components/zichan/ly/LY.jsx'));
const KJ = lazy(()=>import('../components/zichan/kj/KJ.jsx'));
// 客户
const KH = lazy(()=>import('../components/kehu/KH.jsx'));
const KHGL = lazy(()=>import('../components/kehu/khgl/KHGL.jsx'));
const QYLXR = lazy(()=>import('../components/kehu/qylxr/QYLXR.jsx'));
const ZQGLY = lazy(()=>import('../components/kehu/zqgly/ZQGLY.jsx'));

// 招商
const ZS = lazy(()=>import('../components/zhaoshang/ZS.jsx'));
const KJDJ = lazy(()=>import('../components/zhaoshang/kjdj/KJDJ.jsx'));
const ZK = lazy(()=>import('../components/zhaoshang/zk/ZK.jsx'));
const ZY = lazy(()=>import('../components/zhaoshang/zy/ZY.jsx'));

//物业服务
const WYFW = lazy(()=>import('../components/wuyefuwu/WYFW.jsx'));
const ZQGL = lazy(()=>import('../components/wuyefuwu/zqgl/ZQGL.jsx'))
const ZHBX = lazy(()=>import('../components/wuyefuwu/zhbx/ZHBX.jsx'))
const BXSZ = lazy(()=>import('../components/wuyefuwu/bxsz/BXSZ.jsx'))
const GLYGG = lazy(()=>import('../components/wuyefuwu/glygg/GLYGG.jsx'))
const GLYFK = lazy(()=>import('../components/wuyefuwu/glyfk/GLYFK.jsx'))
const WYXZ = lazy(()=>import('../components/wuyefuwu/wyxz/WYXZ.jsx'))


const Login = lazy(()=>import('../views/login/Login.jsx'));
const Register = lazy(()=>import('../views/register/Register.jsx'));
const ForgetPwd = lazy(()=>import('../views/ForgetPwd/ForgetPwd.jsx'));
const Tool=lazy(()=>import('../api/Tool.jsx'))



// 项目管理
const Xiang = lazy(()=>import('../components/xiangmu/xiang/Xiang.jsx'));

// 普通导出,  需要使用 { routes } 引入
export let navs = [
    // 资产
         {
            path:'zichan',
            title:'资产',
            icon:<AppstoreOutlined/>,
            element:<ZC />,
            children:[
                {
                    path:'ly',
                    title:'楼宇',
                    element:<LY />,
                },
                {
                    path:'kj',
                    title:'空间',
                    element:<KJ />,
                }
            ]
        },
    // // 客户
        {
            path:'kehu',
            title:'客户',
            icon:<AppstoreOutlined/>,
            element:<KH />,
            children:[
                {
                    path:'khgl',
                    title:'客户管理',
                    element:<KHGL />,
                },
                {
                    path:'qylxr',
                    title:'签约联系人',
                    element:<QYLXR />,
                },
                {
                    path:'zqgly',
                    title:'租期管理员',
                    element:<ZQGLY />,
                },
            ]
        },
    // // 招商
        {
            path:'zhaoshang',
            title:'招商',
            icon:<AppstoreOutlined/>,
            element:<ZS />,
            children:[
                {
                    path:'kjdj',
                    title:'空间定价',
                    element:<KJDJ />,
                },
                {
                    path:'zk',
                    title:'租控',
                    element:<ZK />,
                },
                {
                    path:'zy',
                    title:'租约',
                    element:<ZY />,
                },
            ]
        },
    // // 物业服务
        {
            path:'wuyefuwu',
            title:'物业服务',
            icon:<AppstoreOutlined/>,
            element:<WYFW />,
            children:[
                {
                    path:'zqgl',
                    title:'租期管理',
                    element:<ZQGL />,
                },
                {
                    path:'zhbx',
                    title:'租户报修',
                    element:<ZHBX />,
                },
                {
                    path:'bxsz',
                    title:'保修设置',
                    element:<BXSZ />,
                },
                {
                    path:'glygg',
                    title:'管理员公告',
                    element:<GLYGG />,
                },
                {
                    path:'glyfk',
                    title:'管理员反馈',
                    element:<GLYFK />,
                },
                {
                    path:'wyxz',
                    title:'物业须知',
                    element:<WYXZ />,
                }
            ]
        },
];

const routes=[
{
    path:'/',
    element:<Navigate to="/home"/>
},
{
    path:'/home',
    element:<Tool comp={<MyLayout/>} url='/login'/>,
    children:[...navs]
},
{
    path:'/login',
    name:'登录',
    element:<Login />
},
{
    path:'/register',
    name:'注册',
    element:<Register />
},
{
    path:'/forgetpwd',
    name:'注册',
    element:<ForgetPwd />
}

]

function MyRouter(){
    return useRoutes(routes);
};
export default MyRouter;